package com.b.repository;


import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import com.b.domain.Order;


/**
 * @Description 
 * @Author jdj
 * @Date 2025/7/25
 */
public interface OrderRepository extends ElasticsearchRepository<Order,String> {
    Page<Order> findByUserIdAndProductId(Integer userId, Integer productId, PageRequest pageRequest);

    Order searchById(String attr0);

    void deleteById(String id);

    // 按用户ID查询
    Page<Order> findByUserId(Integer userId, Pageable pageable);

    // 按商品ID查询
    Page<Order> findByProductId(Integer productId, Pageable pageable);

    // 按用户ID和商品ID查询
    Page<Order> findByUserIdAndProductId(Integer userId, Integer productId, Pageable pageable);

    // 按状态查询
    Page<Order> findByStatus(String status, Pageable pageable);

    // 按用户ID和状态查询
    Page<Order> findByUserIdAndStatus(Integer userId, String status, Pageable pageable);

    // 按商品ID和状态查询
    Page<Order> findByProductIdAndStatus(Integer productId, String status, Pageable pageable);

    // 按用户ID、商品ID和状态查询
    Page<Order> findByUserIdAndProductIdAndStatus(Integer userId, Integer productId, String status, Pageable pageable);

    /**
     * 根据时间范围查询订单
     */
    List<Order> findByOrderTimeBetween(Date startDate, Date endDate);


}

